package com.ibm.util;

import java.util.ArrayList;

import com.fasterxml.jackson.databind.node.ArrayNode;
import com.ibm.datamodel.timeseries.TimeSeriesSchema;
import com.ibm.interfaces.ITimeSeriesSchema;
import com.ibm.util.exception.CPSException;


public class MockupSchemaCache extends SchemaCache{
	
	public void addSchema(String tenantId, String schemaId, String schemaString) throws CPSException{
		ArrayNode tags = (ArrayNode) JSONUtility.fromString(schemaString);
		ITimeSeriesSchema schema = new TimeSeriesSchema(tenantId, schemaId, tags, 1);
		schemaMap.put(schemaId, schema);
		String format = "json";
		schematypeMap.put(schemaId, format);
	}

	@Override
	public ITimeSeriesSchema getSchema(String tenantid, String schemaid,
			ArrayList<String> type) throws CPSException {
		if (!schemaMap.containsKey(schemaid)) {
			return null;
		}
		ITimeSeriesSchema ret = schemaMap.get(schemaid);
		if (tenantid.equals(ret.getUserID())) {
			type.add(schematypeMap.get(schemaid));
			return ret;
		}
		return null;
	}
	
}
